<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	response.setHeader("X-Frame-Options","SAMEORIGIN");
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>中国安全防范技术行业协会台管理系统</title>
<jsp:include page="../../public/public.jsp"/>
	
</head>
<body class="easyui-layout">
<input type="hidden" value="3" id="roleId"/>
	<!--头部  -->
	<div data-options="region:'north',border:false" style="height:60px;background-color:white-space;padding:10px">
		<table style="width:100%; height:100%" cellpadding="0" cellspacing="0">
	      <tr>
	      <td>
		   <%--  <img alt="LOGO" src="<%=basePath%>images/sys/login_01.gif" height="30px" width="300px"/> --%>
		      <font style="font-family:'黑体';font-size:16px;color:black;font-weight:bold;">中国安全防范技术行业协会后台管理系统</font>
          </td>
          <td width="180" align="left" style="padding-right:30px;color:#0470BC; cursor: pointer;" onclick="updatePwd()">
          	欢迎你 &nbsp;:&nbsp;&nbsp;${sessionScope.userinfo.showName}
          </td>
          
          <td width="100" align="center">
          <img alt="" src="<%=basePath%>images/sys/close.png" height="20" style="cursor: pointer;" onclick="toLogin()">
          </td>
          </tr>
	      <tr><td colspan="3" bgcolor="#0470BC" height="1"></td></tr>
	   </table>
		
	
	</div>
	<div data-options="region:'west',split:true,title:'菜单管理'" style="width:250px;padding:10px;" id="shou">
	
	<!--手风琴start  -->
				<div class="easyui-accordion"  style="width:100%;height:100%;">
						
						<c:forEach items="${ls}" var="menu">
		    				<div title='${menu.text}'>
		    				<!--easyUI tree 菜单  -->
								<ul class="easyui-tree" data-options="url:'<%=basePath %>menu/queryMenuTree?id=${menu.id}',method:'post',animate:true,dnd:true"></ul>
							</div>
						</c:forEach>
				</div>
	<!--手风琴start  -->
	</div>
	<!-- 底部 -->
	<div data-options="region:'south',border:false" style="height:50px;background-color:white-space;padding:10px;">
		<table style="width:100%; height:100%" cellpadding="0" cellspacing="0">
	      <tr> 
          <td width="80" align="right" style="padding-right:30px;color:#0470BC;">
          <input type="hidden" id="userNameId" value="${sessionScope.userinfo.userName}"/>
          	欢迎你 &nbsp;:&nbsp;&nbsp;${sessionScope.userinfo.showName}	
          </td>
           <td width="20" align="center" style="padding-right:30px;color:#0470BC;">
         	 您的权限是&nbsp;:&nbsp;&nbsp;${sessionScope.userinfo.roleName}
          	
          </td>
          <td width="2" align="center" >
          <img alt="" src="<%=basePath%>images/sys/login_15.gif" height="30">
          </td>
          <td width="120" align="center" style="padding-right:30px;color:#0470BC;">
         	当前时间是&nbsp;:&nbsp;&nbsp;<span id="timeId"></span>
          	
          </td>
          </tr>
	   </table>
	</div>
	<div data-options="region:'center',title:'功能管理'">
	
		<!--中间部分start  -->
			<div id="tabs-content" class="easyui-tabs" data-options="fit:true,border:false,plain:true">
			   <div title="Welcome" style="padding:10px">
			     <table width="100%" height="100%"><tr>
			     	<td align="center" valign="middle">
			     			
			     			
			     			<h2 style="font-size: 35px;">欢迎登录中国安全防范技术行业协会后台管理系统</h2>
			     			
			     	</td></tr>
			     </table>
			   </div>
			   
			</div>
		<!--中间部分end  -->
	
	</div>
	<!--修改密码 stat  -->
	<div id="pwdWindow" class="easyui-window" title="修改密码" data-options="modal:true,closed:true,iconCls:'icon-edit'" style="width:400px;height:220px;padding:10px;">
		<form id="pwdForm" method="post">
	  		<table align="center" style="margin-top:20px">
	    		<tr style="height: 30px">
	    			<td>旧密码：</td>
	    			<td>
	    				<input  id="oldUserPass"  type="password" class="easyui-textbox" data-options="width:150,required:true"/>
	    			</td>
	    		</tr>
	    		<tr style="height: 30px">
	    			<td>新密码：</td>
	    			<td>
	    				<input  id="newUserPass" type="password" class="easyui-textbox" data-options="width:150,required:true"/>
	    			</td>
	    		</tr>
	    		<tr style="height: 30px">
	    			<td>确认新密码：</td>
	    			<td>
	    				<input  id="newUserPassAgain" type="password" class="easyui-textbox" data-options="width:150,required:true"/>
	    			</td>
	    		</tr>
	    		<tr>
	    			<td colspan="2" align="middle" style="padding-left:20px">
	    			  <a href="javascript:void(0)" data-options="iconCls:'icon-save'" class="easyui-linkbutton" onclick="pwdSubmit()">保存</a>
	    			  <a href="javascript:void(0)" data-options="iconCls:'icon-cancel'" class="easyui-linkbutton" onclick="$('#pwdWindow').window('close');">取消</a>
	    			</td>
	    		</tr>
	   		</table>
		</form>
	</div>
	<!--修改密码 end  -->
</body>
<script type="text/javascript">

/* 左边菜单栏   点击菜单触发  easyUI选项卡 */
$('.easyui-tree').tree({
	
    onClick: function(node){
    	
    	if ($('#tabs-content').tabs('exists', node.text)){ 
	        $('#tabs-content').tabs('select', node.text);  
	    } else {  
	    	if(node.houUrl==null || node.houUrl=="" || node.houUrl=="null"){
	    		return;
	    	}else{
	    		 var content = '<iframe scrolling="auto" frameborder="0"  src="<%=basePath %>'+node.houUrl+'" style="width:100%;height:100%;"></iframe>';	
	    		 
	    	}
	         $('#tabs-content').tabs('add',{  
	            title:node.text,
	            //href:node.url,
	            content:content,  
	            closable:true 
                //iconCls: node.iconCls
	         });  
	    } 
    }
});
/* 修改密码 */
function updatePwd(){
	$('#pwdForm').form('reset');
	/* 打开修改页面 */
	$('#pwdWindow').window('open');
}
/* 保存修改的密码 */
function pwdSubmit(){
		/* 旧密码 */
	   var oldUserPass = $("#oldUserPass").textbox('getValue').replace(/\s/g, "");
		/* 新密码 */
	   var newUserPass = $("#newUserPass").textbox('getValue').replace(/\s/g, "");
		/* 再次输入的新密码 */
	   var newUserPassAgain = $("#newUserPassAgain").textbox('getValue').replace(/\s/g, "");
		if(oldUserPass==""){
			 $.messager.alert("提示","旧密码不允许为空!","info");
			   return;
		}
		if(newUserPass==""){
			 $.messager.alert("提示","新密码不允许为空!","info");
			   return;
		}
		if(newUserPassAgain==""){
			 $.messager.alert("提示","再次输入的密码不允许为空!","info");
			   return;
		}
		var username = $("#userNameId").val();
		 
	   if(newUserPass!=newUserPassAgain){
		   $.messager.alert("提示","两次输入密码不一致!","info");
		   return;
	   }
	   if(oldUserPass == newUserPass){
		   $.messager.alert("提示","新密码和旧密码不能一致!","info");
		   return;
	   }
		 $.ajax({
			 	url: '<%=basePath%>user/updatePwd',
		        type: 'POST',
		        data: {
		        	'userName':username,
		        	'userPass':oldUserPass,
		        	'newUserPass':newUserPass
		        },
		        dataType: 'json',
		        success: function(data){
		        	var code = data.code;
		        	var msg = data.msg;
		        	var row = data.row;
		        	if(code=="404"){
		        		alert(msg);
		        		  location.href='<%=basePath %>login';  
		        		return;
		        	}
		        	$.messager.alert("提示",msg,"info");
		        	if(row>=0 && code=="200"){
		        		$('#pwdWindow').window('close');
		        	}
		        	
		        }
		 });
   }
	
/* 退出到登录页面   登录页面会刷新清空session */
function toLogin(){
	$.messager.confirm('确认','您确认想要退出吗？',function(r){    
	    if (r){    
	        location.href='<%=basePath %>login';    
	    }    
	});  
}
/* 获取当前时间 */
function currentTime(){
	var d = new Date(),str = '';
	 str += d.getFullYear()+'年';
	 str  += d.getMonth() + 1+'月';
	 str  += d.getDate()+'日';
	 str += d.getHours()+'时'; 
	 str  += d.getMinutes()+'分'; 
	str+= d.getSeconds()+'秒'; 
	return str;
}
/* 一秒钟刷新一次 */
setInterval(function(){$('#timeId').html(currentTime)},1000);

    </script>
</html>